package com.example.httplibrary.mvp.proxy;



import com.example.httplibrary.mvp.BasePresenter;
import com.example.httplibrary.mvp.BaseView;

import androidx.fragment.app.Fragment;

/**
 * Author: 李巷阳
 * Date: 2020/6/22
 * Part:
 * Description:
 */
public class FragmentMvpProxyImpl<V extends BaseView> extends MvpProxyImpl<V> implements FragmentMvpProxy {
    public FragmentMvpProxyImpl(V view) {
        super(view);
    }

    public void bindAndCreatePresenter(Fragment fragment) {
        super.bindAndCreatePresenter();
        // 一定要解绑
        for (BasePresenter presenter : mPresenters) {
            // 利用Lifecycle 把activity生命周期绑定至Presenter
            fragment.getLifecycle().addObserver(presenter);

        }
    }
}
